<?php
namespace Application\Model;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
class Persona 
{
    
    private $id;
    private $clasificacion;
    private $nivel;
    private $ruc;
    private $razonSocial;
    private $telefono;
    private $celular;
    private $email;
    private $ciudad;
    private $observacion;
    private $proveedor;
    private $cliente;
    private $funcionario;
    private $creadoPor;
    private $creadoFecha;
    private $modificadoPor;
    private $ultimaModificacion;
   
    
  
    public function exchangeArray($data)
     {
         $this->id              = (!empty($data['id'])) ? $data['id'] : null;
         $this->clasificacio    = (!empty($data['clasificacio'])) ? $data['clasificacio'] : null;
         $this->nivel           = (!empty($data['nivel'])) ? $data['nivel'] : null;
         $this->nivel           = (!empty($data['nivel'])) ? $data['nivel'] : null;
         $this->nivel           = (!empty($data['nivel'])) ? $data['nivel'] : null;
         $this->nivel           = (!empty($data['nivel'])) ? $data['nivel'] : null;
         $this->nivel           = (!empty($data['nivel'])) ? $data['nivel'] : null;
         $this->nivel           = (!empty($data['nivel'])) ? $data['nivel'] : null;
         $this->nivel           = (!empty($data['nivel'])) ? $data['nivel'] : null;
         
     }
    
    
    private function cargaAtributos($datos=array())
    {
        $this->nombre=$datos["nombre"];
        $this->correo=$datos["email"];
    }
     public function getUsuarios()
        {
            $datos = $this->select();
            return $datos->toArray();
        }
     public function getUsuarioPorId($id)
     {
        $id  = (int) $id;
        $rowset = $this->select(array('id' => $id));
        $row = $rowset->current();
        
        if (!$row) {
            throw new \Exception("No hay registros asociados al valor $id");
        }
        
        return $row;
     }
      public function addUsuario($data=array())
        {
             self::cargaAtributos($data);
            /*
             echo $this->nombre;
             echo "<br>";
             echo $this->correo;
             */
             $array=array
             (
                'nombre'=>$this->nombre,
                'correo'=>$this->correo
             );
               $this->insert($array);
               
        }
       
        

    public function updateUsuario($id, $data=array())
    {
        
        $this->update($data, array('id' => $id));
    }

    public function deleteUsuario($id)
    {
        $this->delete(array('id' => $id));
    }
}


